-
Notifications
You must be signed in to change notification settings - Fork 0
Fix Windows tray icon callbacks failing due to thread safety issues #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Pass tkinter_root to Windows tray implementation - Schedule all callbacks on main Tkinter thread using root.after() - Fixes issue where quit and show window didn't work from tray menu - Ensures thread-safe UI updates from tray icon events Co-authored-by: bryfur <7673964+bryfur@users.noreply.github.com>
Co-authored-by: bryfur <7673964+bryfur@users.noreply.github.com>
- Extract common pattern into _schedule_callback helper method - Improves code maintainability and readability Co-authored-by: bryfur <7673964+bryfur@users.noreply.github.com>
Co-authored-by: bryfur <7673964+bryfur@users.noreply.github.com>
|
@copilot I dont like passing the tkinter root in, should the callbacks just all pass in wrapped in tkinter after, ensure all tray implementations would work correctly with that setup |
… tray implementations - Remove tkinter_root parameter from TrayIcon and WindowsTrayImpl - Wrap all callbacks with lambda: root.after(0, callback) in MainWindow._setup_tray() - This keeps tray implementations simpler and platform-agnostic - Thread safety is now handled at the callback registration point Co-authored-by: bryfur <7673964+bryfur@users.noreply.github.com>
Done! I've refactored the solution to wrap callbacks with The callbacks are now wrapped in on_show=lambda: self.root.after(0, self._show_window),
on_quit=lambda: self.root.after(0, self.quit_app),
# etc.This approach ensures thread safety while maintaining clean separation of concerns. Commit: 9eeba2e |
|
@copilot can we simplify the macos tray now that callbacks are always on the main loop |
…alling - Remove performSelectorOnMainThread calls since callbacks are already wrapped with root.after() - Call setupStatusBar and updateMonitorMenuTitle_ directly - already on main thread via async_mainloop - Reduce setup delay from 0.3s to 0.1s - Update documentation to reflect simplified implementation Co-authored-by: bryfur <7673964+bryfur@users.noreply.github.com>
Co-authored-by: bryfur <7673964+bryfur@users.noreply.github.com>
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.